<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>房台收银</title>
		<link rel="stylesheet" href="dist/css/layui.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/shouy.css" />
		<style type="text/css">
			.mui-popup-input input{width: 100%; height: 26px; line-height: 21px; padding: 0 5px; border: 1px solid rgba(0, 0, 0, .3); border-radius: 0; background: #fff;}
			.mui-popup-input input,.mui-popup-input textarea{margin-top: 5px; display: block; width: 90%; font-size: 14px;}
			.mui-popup-input textarea{padding: 5px;}
			.mui-popup-input{padding-bottom: 15px; width: 100%;}
			.mui-popup-text{font-size: 16px; line-height: normal; padding-bottom: 5px; text-align: left;}
			.mui-popup-inner{position: relative; padding: 25px 15px 0; border-radius: 13px 13px 0 0; background: white;}
			.mui-popup {position: fixed; z-index: 10000; top: 50%; left: 50%; display: none; overflow: hidden; width: 270px; -webkit-transition-property: -webkit-transform, opacity; transition-property: transform, opacity; -webkit-transform: translate3d(-50%, -50%, 0) scale(1.185); transform: translate3d(-50%, -50%, 0) scale(1.185); text-align: center; opacity: 0; color: #000; border-radius: 13px;}
			.mui-popup.mui-popup-in {display: block; -webkit-transition-duration: 400ms; transition-duration: 400ms; -webkit-transform: translate3d(-50%, -50%, 0) scale(1); transform: translate3d(-50%, -50%, 0) scale(1); opacity: 1;}
			.mui-popup-buttons {position: relative; border-top: 1px solid #E6E6E6; display: -webkit-box; display: -webkit-flex; display: flex; height: 44px; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center;}
			.mui-popup-button {font-size: 17px; line-height: 44px; position: relative; display: block; overflow: hidden; box-sizing: border-box; width: 50%; float: left; height: 44px; padding: 0 5px; cursor: pointer; text-align: center; white-space: nowrap; text-overflow: ellipsis; color: #007aff; background: white; -webkit-box-flex: 1; *width: 46%; *float: left;}			
			.mui-popup-button:first-child {border-radius: 0 0 0 13px; border-left: 1px solid #E6E6E6;}
			.mui-popup-button:last-child {border-radius: 0 0 13px;}
			.mui-popup-button.mui-popup-button-bold {font-weight: 600;}
			.mui-popup-backdrop {position: fixed; z-index: 998; top: 0; right: 0; bottom: 0; left: 0; -webkit-transition-duration: 400ms; transition-duration: 400ms; opacity: 0; background: rgba(0, 0, 0, .4); *background: #000000; *opacity:0.9; *filter:alpha(opacity=9);}
			.mui-popup-backdrop.mui-active {opacity: 1;}
			
		</style>
		
	</head>

	<body>
		<div class="wrap">
			<div class="sy_header clearfix">
				<div class="sy_hleft">
					<div class="sy_logobox">
						<div class="sy_logo"><img src="img/logo-ma.png"></div>
						<p id="app_name"></p>
					</div>
					<ul class="sy_nav clearfix">
						<li>
							<a href="index.html">
								<div class="iconfont icon-shouyintai"></div>
								<p>快速收银</p>
							</a>
						</li>
						<li>
							<a href="product_pay.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>商品收银</p>
							</a>
						</li>
						<li class="active">
							<a href="house.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>房台收银</p>
							</a>
						</li>
						<li>
							<a href="xiaof_member.html">
								<div class="iconfont icon-weibiaoti-"></div>
								<p>我的会员</p>
							</a>
						</li>
						<li>
							<a href="jingybb.html">
								<div class="iconfont icon-jingyingbaobiao"></div>
								<p>经营报表</p>
							</a>
						</li>
					</ul>
				</div>
				<div class="sy_hright">
					<div class="sy_shopbox">
						<div class="sy_simg"><img id="toux" src="" style="background-color: #FFFFFF;"></div>
						<div class="sy_sinfo">
							<p class="sy_snam">店名：<span id="sname"></span></p>
							<p>用户：<span id="user"></span></p>
							<p class="exit" onclick="exit()">退出登陆</p>
						</div>
					</div>
				</div>
			</div>

			<div id="house_show" class="sy_pconbox clearfix">
				<div class="sy_proleft">
					<ul id="house_type" class="sy_pronav">
						<li class="active" data-id="0">
							<a>全部</a>
						</li>
					</ul>
					<div style="height: 500px;overflow-y: auto;">
						<ul class="fant_list clearfix">

						</ul>
					</div>
				</div>
				<div class="sy_proright">
					<div class="sy_probt" style="padding: 0 10px;">
						<span ><em id="house_name" style="color: #333;"></em>&nbsp;<em style="font-size: 12px;font-weight: normal; color: #999999;" id="add_time"></em></span>
						<span style="float: right;">总计：<em id="htotal">¥0.00</em></span>
					</div>
					<ul id="goods_list1" class="sy_proxlist fangt_proxlist">						
						<div class="no_style">
							<p><img src="img/none.png"></p>
							<p class="nr">请选择房台~</p>
						</div>
					</ul>
					<div class="sy_prorb">
						<div class="sy_ftgnbtn clearfix">
							<span class="kaits">开台</span>
							<span class="diands">点单</span>
							<span class="guants">关台</span>
							<span class="dayins">打印</span>
						</div>
						<div class="sy_probtnbox clearfix">
							<button type="button" onclick="sao_pay()" class="sy_probtn orange">收款码</button>
							<button type="button" onclick="jiz_tck()" class="sy_probtn blue">记账</button>
						</div>
					</div>
				</div>
			</div>
			<div id="goods_show" style="display: none;" class="sy_pconbox clearfix">
				<div class="sy_proleft">
					<ul id="goods_type" class="sy_pronav clearfix">
						<li class="active">
							<a>全部</a>
						</li>
					</ul>
					<div style="height: 470px;overflow-y: auto;">
						<div class="sy_prolbox">
							<ul class="sy_prolist clearfix" style="padding-bottom: 80px;">

							</ul>
							<div id="demo2"></div>
						</div>
					</div>
				</div>
				<div class="sy_proright">
					<div class="sy_probt2">
					<span class="sy_ssk"><input id="keyword" class="sousuok" type="text" placeholder="输入商品名或关键词查询"></span>
					<span><a href="#" onclick="search_gd()" class="iconfont icon-sousuo"></a></span>
					</div>
					<div class="sy_probt">
						<span>已选商品(<em id="nums">0</em>)</span>
						<a href="javascript:clear_cart1();" style="float: right; padding-right: 15px; color: #009E94; font-size: 14px;">清除</a>
					</div>
					<ul id="goods_list" class="sy_proxlist">
					</ul>
					<div class="sy_prorb">
						<div class="sy_prozj">总计：<em>¥</em><em id="totals">0.00</em></div>
						<div class="sy_probtnbox clearfix">
							<button type="button" onclick="qr(this)" class="sy_probtn orange">确认</button>
							<button type="button" onclick="back()" class="sy_probtn blue">返回</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="tanchu" style="display: none; position: relative; width: 960px;">
		<div class="mui-popup mui-popup-in" style="display: block;">
			<div class="mui-popup-inner">
				<!--<div class="mui-popup-title">Hello MUI</div>-->
				<div class="mui-popup-text">就餐人数：</div>
				<div class="mui-popup-input"><input id="people_nums" onkeyup="clearNoNum(this)" type="text" autofocus="" placeholder="请输入您的就餐人数"></div>
				<div class="mui-popup-text">备注：</div>
				<div class="mui-popup-input"><textarea id="memo" placeholder="请输入您的备注"></textarea></div>
			</div>
			<div class="mui-popup-buttons clearfix"><span class="mui-popup-button" onclick="cans()">取消</span><span onclick="qr2(this)" class="mui-popup-button mui-popup-button-bold">确定</span></div>
		</div>
		<div class="mui-popup-backdrop mui-active" style="display: block;"></div>
		</div>
	</body>

</html>
<script src="dist/layui.all.js"></script>
<script src="dist/json2.js"></script>
<script type="text/javascript" src="dist/jquery-1.11.0.min.js"></script>
<script src="dist/jquery.lazyload.min.js"></script>
<script src="dist/layui.all.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/house.js"></script>
<script>
	
	layui.use(['laypage', 'layer'], function() {
		var laypage = layui.laypage,
			layer = layui.layer;
	});
	var list = {};
	var cart = {};

	function set_goods(goods) {
		append_html = "";
		for(var g in goods) {
			var gd = goods[g];
			append_html += '<li data-tp='+gd['trade_id']+' data-dk=' + gd['dk_price'] + ' data-zs=' + gd['zs_price'] + ' data-id=' + gd['id'] + ' data-price=' + gd['sale_price'] + ' data-name=' + gd['goods_name'] + '><a>' +
				'<div class="sy_proimg">' +
				'<span><img src="' + gd['thumb'] + '"></span>' +
				'<span class="propri">¥' + gd['sale_price'] + '</span>' +
				'</div>' +
				'<div class="sy_pronam">' + gd['goods_name'] + '</div>' +
				'</a>' +
				'</li>';
		}
		return append_html;
	}

	
	
	function add_num(obj, id) {
		var num = parseFloat(cart[id]['num']);
		var zs = parseFloat(cart[id]['zs']);
		var dk = parseFloat(cart[id]['dk']);
		cart[id]['num'] = num + 1;
		cart[id]['total_zs'] = cart[id]['total_zs'] + zs;
		cart[id]['total_dk'] = cart[id]['total_dk'] + dk;
		$("#totals").text((parseFloat($("#totals").text()) + parseFloat(cart[id]['price'])).toFixed(2));
		$(obj).next("input").val(num + 1);
		check_stock($(obj).next("input"), id);
	}

	function ms_num(obj, id) {
		var num = parseFloat(cart[id]['num']);
		var zs = parseFloat(cart[id]['zs']);
		var dk = parseFloat(cart[id]['dk']);
		if(num >= 1) {
			cart[id]['num'] = num - 1;
			$(obj).prev("input").val(num - 1);
			cart[id]['total_zs'] = cart[id]['total_zs'] - zs;
			cart[id]['total_dk'] = cart[id]['total_dk'] - dk;
			$("#totals").text((parseFloat($("#totals").text()) - parseFloat(cart[id]['price'])).toFixed(2));
		}
	}

	function set_price() {
		if(!$.isEmptyObject(cart)) {
			var total_price = 0;
			for(var o in cart) {
				total_price += cart[o]['num'] * cart[o]['price'];
			}
			$("#totals").text(total_price.toFixed(2));
		} else {
			$("#totals").text(0.00);
		}
	}

	function change(obj, id) {
		var v = $(obj).val();
		if(v == "" || isNaN(v)) {
			$(obj).val(cart[id]['num']);
		} else if($(obj).val() <= 0) {
			$(obj).val(0);
		}
		cart[id]['num'] = $(obj).val();
		set_price();
		check_stock($(obj), id);
	}

	function check_stock(obj, goods_id) {
		$.ajax({
			url: APP.api_url + "Sy/check_stock",
			data: {
				goods_id: goods_id,
				nums: $(obj).val(),
				app_id: APP.app_id,
				time: Date.parse(new Date())
			},
			success: function(data) {
				if(data.code != 200) {
					layer.msg(data.msg);
				}
			}
		})
	}
	$(function() {
		set_info();
		get_houses();
	})
</script>